﻿using Restaurant.Business;
using Restaurant.Common;
using Restaurant.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Restaurant.Site
{
    /// <summary>
    /// 桌子Site
    /// </summary>
    public class TableSite
    {
        TableBusiness TableBusiness = null;

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public async Task<OperationResult> AddAsync(CompanyTable table)
        {



            if (null == table.SubCompany_Id)
                return new OperationResult(OperationResultType.Error, "公司ID不能为空");
            if (string.IsNullOrEmpty(table.TableNum))
                return new OperationResult(OperationResultType.Error, "桌名不能为空");
            if (string.IsNullOrEmpty(table.Operator))
                return new OperationResult(OperationResultType.Error, "操作人不能为空");
            if (null == TableBusiness)
                TableBusiness = new TableBusiness();

            return await TableBusiness.AddAsync(table);


        }
          
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public async Task<OperationResult> DeleteAsync(long id)
        {
            if (id < 1)
                return new OperationResult(OperationResultType.Error, "ID错误");

            if (null == TableBusiness)
                TableBusiness = new TableBusiness();

            return await TableBusiness.DeleteAsync(id);
        }

        /// <summary>
        /// 获取分公司下桌子
        /// </summary>
        /// <param name="subCompanyId">分公司Id</param>
        /// <returns></returns>
        public async Task<OperationResult> GetAllBySubComanyId(Guid subCompanyId)
        {
            if (null == subCompanyId)
                return new OperationResult(OperationResultType.Error, "公司ID不能为空");
            if (null == TableBusiness)
                TableBusiness = new TableBusiness();

            return await TableBusiness.GetAllBySubComanyId(subCompanyId);
        }


    }
}
